﻿namespace RialternativeSample.Client.Helpers
{
    using Microsoft.Practices.Unity;

    /// <summary>
    /// Provides some helps for using unity.
    /// </summary>
    public static class UnityHelper
    {
        /// <summary>
        /// Object locker for singleton pattern.
        /// </summary>
        private static object syncRoot = new object();

        /// <summary>
        /// The unity container.
        /// </summary>
        private static volatile IUnityContainer container;

        /// <summary>
        /// Gets the unity container.
        /// </summary>
        /// <value>The unity container.</value>
        public static IUnityContainer UnityContainer
        {
            get
            {
                lock (syncRoot)
                {
                    if (container == null)
                    {
                        container = new UnityContainer();
                    }
                }

                return container;
            }
        }
    }
}
